package co.edu.unal.geditor.view;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;

import co.edu.unal.geditor.model.GraphElement;
import co.edu.unal.geditor.model.TextElement;

public class TextGraphView extends ElementView
{
	public TextGraphView( GraphElement ge )
	{
		super( ge );

		assert ge instanceof TextElement;
	}

	@Override
	public void paint( Graphics g )
	{
		Point ul = m_owner.getUpLeft();
		Point bd = m_owner.getDownRight();
		Color color = m_owner.getLinesColor();
		Color bColor = m_owner.getFillColor();
		

		//TODO: casting ...
		String text = ((TextElement)m_owner).getText();	
		Font font=((TextElement)m_owner).getFont();

		
		g.setColor(bColor);
		g.fillRect(ul.x, ul.y, m_owner.getBoundBox().getWidth(), m_owner.getBoundBox().getHeight());
		g.setColor( color );
		g.setFont(font);
		g.clipRect(ul.x, ul.y, m_owner.getBoundBox().getWidth(), m_owner.getBoundBox().getHeight());
		g.drawString( text, ul.x+5, bd.y-5 );
		g.setClip(null);
		
		
		
		
		
		
		super.paint( g );
	}
}

